var SubCreateRoomWindow = CreateRoomWindow.extend({
    _ccsFileName: res.CreateRoomWindow_json,

    _handleSpecialDepend: function (btnname, btndata) {
        CreateRoomWindow.prototype._handleSpecialDepend.call(this);
        // cc.log('CreateRoomWindow ... _handleSpecialDepend', this._curSelectedTab);
        //特殊处理
        // if (this._curSelectedTab == 'btn_1') {
        //     var pdkNumofCardsPerUser = this._cbList['pdkNumofCardsPerUser_0'];
        //     var pdk3Abomb = this._cbList['pdk3Abomb_0'];
        //     var pdk3A1bomb = this._cbList['pdk3A1bomb_0'];
        //     pdk3Abomb.setVisible(pdkNumofCardsPerUser.getChildByName('checkBox').isSelected());
        //     pdk3A1bomb.setVisible(pdkNumofCardsPerUser.getChildByName('checkBox').isSelected());
        // }

        // this.showBtnFangkaNum(btnname, btndata);
    },


    /**
     * 点击创建
     * @protected
     */
    _clickCreate: function () {
        mRoom.wanfaMap = {};
        mRoom.wanfaMap['AutoReady'] = false;
        mRoom.wanfa = '';
        mRoom.special_gz = [];
        mRoom.wanfaArr = [];
        for (var id in this._cbList) {
            if (this._cbList.hasOwnProperty(id)) {
                var cb = this._cbList[id];
                var userData = cb.getUserData();
                var checkBox = cb.getChildByName('checkBox');
                // 选项框不存在
                if (!checkBox || !cc.sys.isObjectValid(checkBox)) {
                    continue;
                }
                // 不可见或者未被选中
                if (!cb.isVisible() || !checkBox.isSelected()) {
                    continue;
                }
                var key = userData.key;
                // 以 '_' 开头的直接忽略
                if (key.indexOf('_') == 0) {
                    continue;
                }

                if (key.indexOf('_') > 0) {
                    key = key.split('_')[0];
                }
                var value = userData.val;
                var desp = this._getSpecialDesp(key, userData.desp);
                // 生成option
                mRoom.wanfaMap[key] = value;
                // 添加玩法
                if (gameData.useNewClub && this._clubId && this._clubHunZhuoData && this._clubHunZhuoData[this._curSelectedTab] && desp.indexOf('人') > -1 && desp.indexOf('房') < 0) {
                    // gameData.useNewClub  快乐麻将混合牌桌字段  2001 带的参数。
                    // 只混合牌桌不能带 人数   （btn_7 转转麻将  btn_8 长沙麻将  btn_9 红肿麻将）
                    // 目前只快乐麻将 麻将玩法 有混合牌桌，才会走这个逻辑！
                } else {
                    if(desp)mRoom.wanfaArr.push(desp);
                }
                // 处理特殊参数
                this._generateExtraDespMap(key, desp);
                this._generateSpecialGz(key, desp);
            }
        }
        // 玩法
        mRoom.wanfa = mRoom.wanfaArr.join(',');
        mRoom.wanfaMap.desp = mRoom.wanfa;
        // 特殊规则
        mRoom.wanfaMap.special_gz = mRoom.special_gz;
        this._generateSpecialWanfa();
        if (mRoom.wanfaMap.rounds) {
            mRoom.wanfaMap.jushu = mRoom.wanfaMap.rounds;
        }

        //跑胡子 传 rounds 必须传
        if (mRoom.wanfaMap['mapid'] >= 300 && mRoom.wanfaMap['mapid'] < 400) {
            mRoom.wanfaMap['wanfa'] = 'leiyang';

            if (mRoom.wanfaMap['jushu']) {
                mRoom.wanfaMap['rounds'] = mRoom.wanfaMap['jushu'];
            }
            else if (mRoom.wanfaMap['jushu2']) {
                mRoom.wanfaMap['rounds'] = mRoom.wanfaMap['jushu2'];
            }
            if (mRoom.wanfaMap['mapid'] == app.map_id.LEIYANGZIPAI) {
                mRoom.wanfaMap['wanfa'] = 'leiyang';
            }
            else if (mRoom.wanfaMap['mapid'] == app.map_id.HENGYANGLHQ) {
                mRoom.wanfaMap['wanfa'] = 'hengyang';
            } else if (mRoom.wanfaMap['mapid'] == app.map_id.HENGYANGSHK) {
                mRoom.wanfaMap['wanfa'] = 'shihuka';
            }
        }

        if (this._isSetWanfa) {
            // network.send(2101, {
            //     cmd: 'wanfaClub',
            //     club_id: this._clubId,
            //     options: mRoom.wanfaMap,
            //     map_id: mRoom.wanfaMap['mapid'],
            //     desc: mRoom.wanfaMap.desp
            // });

            if(this._clubId && gameData.useNewClub && !mRoom.wanfaMap['wanjiarenshu0'] && !mRoom.wanfaMap['wanjiarenshu1'] && !mRoom.wanfaMap['wanjiarenshu2'] &&
                !mRoom.wanfaMap['sirenGuding'] && !mRoom.wanfaMap['sanrenSuiji'] && !mRoom.wanfaMap['sanrenGuding'] && !mRoom.wanfaMap['liangrenSuiji'] &&
                !mRoom.wanfaMap['cpCount'] && !mRoom.wanfaMap['maxPlayerCnt'] &&
                !mRoom.wanfaMap['sirenwan'] && !mRoom.wanfaMap['sanrenwan'] && !mRoom.wanfaMap['erren'] &&
                !mRoom.wanfaMap['sanrenwan_1']
            ){
                showAlert('请选择一种牌桌人数');
                return;
            }

            mRoom.wanfaMap['club_id'] = this._clubId;
            network.send(2103, {
                cmd: 'addWanfa',
                club_id: this._clubId,
                options: mRoom.wanfaMap,
                desc: mRoom.wanfaMap.desp,
                map_id: mRoom.wanfaMap['mapid'],
                daikai: false,
                pos: this._setwanfapos
            });

            this.removeFromParent();
        } else {
            // HUD.showLoading("正在创建房间");
            showLoading("正在创建房间");
            mRoom.roomInfo = mRoom.wanfaMap;

            network.start();
            gameData.last3001Data = {
                room_id: 0
                , map_id: mRoom.wanfaMap['mapid']
                , mapid: mRoom.wanfaMap['mapid']
                , daikai: this._isDaikai
                , options: mRoom.wanfaMap
                , club_id: this._clubId
                , timestamp: getCurTimestampMills()
            };
            if(this._setwanfapos == 5){
                gameData.last3001Data.options.pos = this._setwanfapos;
                gameData.last3001Data.options.club_id = this._clubId;
                // gameData.enterRoomWithClubID = this.clubId;
            }
            network.send(3001, gameData.last3001Data);
        }
        this._saveSelected();
    },
});